package dao

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var db *gorm.DB

func DbInit() error {
	var err error
	dsn := "root:6516262abc@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=True&loc=Local"
	db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		fmt.Println("Failed to connect database!!!")
		return err
	}
	err = db.Table("UserInfo").AutoMigrate(&Account{})
	if err != nil {
		return err
	}
	return nil
}

func test() {
	return
}
